package com.wbt.jdk.map;

import java.util.HashMap;

public class TestHash {

    public static void main(String[] args) throws Exception{

        String[] keys = {"gfer","hello","huawei","xiaomi","oppomi","dffdd"};



        for (int i = 0; i<keys.length; i++){
            System.out.println(keys[i] + " : " + hash(keys[i]) + ", index : " + (hash(keys[i]) & 15));
        }

        for (int i = 0; i<keys.length; i++){
            System.out.println(keys[i] + " : " + hash(keys[i]) + ", index : " + (hash(keys[i]) & 31));
        }

    }

    static final int hash(Object key) {
        int h;
        return (key == null) ? 0 : (h = key.hashCode()) ^ (h >>> 16);
    }
}
